<?php
$this->pageTitle = '123Free 登陆认证'; 
$this->logo=$company->logo; 
?>
<script type="text/javascript">
$("#appLoading").show(); 
</script>
<div class="span-11">
    <div id="sidebar">
        <div  id="sidebarview">
            <?php if (count($video) > 0) { ?> 
            <div id='video' >
            <div class="title">热门视频免费看<span class="more"><a href="<?php echo Yii::app()->createUrl('video/list&type=1')?>"><img src="<?php  echo Yii::app()->request->baseUrl.'/images/web/gd.png' ?>"></a></span></div>
                <?php foreach($video as $v){ ?>
                    <div id="showview">
                        <span><a href="<?php echo Yii::app()->createUrl('video/show&id='.$v['id'])?>"><img src="<?php  echo Yii::app()->request->baseUrl.'/'.$v['cover']?>" ></a></span><br>
                        <span style="text-align: center;"><?php  echo $v['title']?></span>
                    </div>
                <?php } ?>
            </div>
            <?php }

            if (count($app) > 0) { ?>
            <div id='app' > 
             <div class="title">热门应用APP免费下载<span class="more"><a href="<?php echo Yii::app()->createUrl('video/list&type=2')?>"><img src="<?php  echo Yii::app()->request->baseUrl.'/images/web/gd.png' ?>"></a></span></div>
                <?php foreach($app as $v){ ?>
                    <div id="showview">
                    <span><a href="<?php echo Yii::app()->createUrl('video/showdown&id='.$v['id'])?>"><img src="<?php  echo Yii::app()->request->baseUrl.'/'.$v['cover']?>" ></a></span><br>
                    <span style="text-align: center;"><?php  echo $v['title']?></span>
                    </div>
                <?php } ?>
            </div>
            <?php } ?>
        </div>
    </div><!-- sidebar -->
</div>
<div class="span-9 last">
    <div id="content"> 

<p id='poster'><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/web/wenzi.png" /></p>
<p id='explain'>请输入手机号码，我们会将上网密码发送到您手机上。</p>
<script type="text/javascript"> 
     var res='';
    $(document).ready(function(){ 
        $("#appLoading").hide(); 
        $("#send_text").click(function(){ 
            $('#errormessage').html('');
            $('#successMessage').html('');
            var mobile = $('#User_mobile').val();
            if(!(/^1[3|4|5|8][0-9]\d{4,8}$/.test(mobile))){
                 $('#User_mobile_em_').attr('style','display:;');
                $('#User_mobile_em_').html("手机号码格式不正确");
                 return false;
            }
            $("#appLoading").show();  
             $.ajax({
                async:true,   
                cache:false,   
                timeout:15000,   
                type:"POST",   
                url:"<?php echo Yii::app()->createUrl('api/verify_mobile')?>",   
                data:{'mobile':mobile},   
                dataType:'json',
                error:function(jqXHR, textStatus, errorThrown){   
                     $("#appLoading").hide();
                     $('#successMessage').html("请求超时,请重新请求");
                },   
                success:function(result){  
                    $("#appLoading").hide();  
                    $("#send_text").addClass('send_click'); 
                    countdown();
                    if(result.code == 0 || result.code == 3){ 
                        $('#send_text').attr('disabled',true);
                        res=result.res;
                         $('#successMessage').html(result.message);
                    }else if(result.code ==2){//用户已注册
                        $('#User_password').attr('value',result.res);
                        $('#password').hide();
                        $('#send_text').hide();
                        $('#successMessage').html(result.message);
                    }else{
                        $('#send_text').attr('disabled',true);
                         $('#successMessage').html(result.message);
                        return false;
                    } 
                }   
             });   
        });
        // $('#user-form').onSubmit(function(){
            // $("#appLoading").show(); 
            // return false;
        // });  
    });
        var t;
        var c = 61;
        function countdown(){  
            c = c - 1; 
            $("#send_text").val('请等待'+ c + '秒');
             if(c == 0){ 
                clearTimeout(t);  
                $('#successMessage').html("直接点击开启免费上网");
                $('#User_password').attr('value',res);
                return false;
            }
           t =setTimeout(function(){countdown();}, 1000); 
        }
        
</script>
  <div class="form"> 
            <?php $form=$this->beginWidget('CActiveForm', array(
                'id'=>'user-form',
                'action'=>Yii::app()->createUrl('api/verify_login'),
                'enableClientValidation'=>true,
                'clientOptions'=>array(
                    'validateOnSubmit'=>true,
                ),
            )); ?>
                <div id='reminds'>
                    <div id="successMessage" style="color: #red;"></div>
                    <div id="errormessage" style="color: red;"> <?php echo empty($errormessage)?'':$errormessage;  ?></div>
                    <?php echo $form->error($model,'mobile'); ?>
                    <?php echo $form->error($model,'password'); ?>
                </div>
                <div class="row" id="mobile">
                    <?php echo $form->textField($model,'mobile',array('placeholder'=>'手机号','value'=>'')); ?>
                </div>

                <div class="row" id='password'>
                    <?php //echo $form->labelEx($model,'password'); ?>
                    <?php echo $form->textField($model,'password',array('placeholder'=>'密码'));  ?>
                    <input type="button" id='send_text' value="获取密码"/>
                </div>
                <div style="clear: both;"></div>

                <div id='remind'></div>
                <div id='test_password'></div>
                <div id='login'>
                    <?php echo CHtml::submitButton('开启免费上网', array('id'=>'submitButton')); ?>
                </div>
                <div id='pact'>
                    <input id="isAgree" type="checkbox" checked="true"> <label for="isAgree">我已阅读接受<a href="#">用户协议</a></label>
                    <br>
                    <a href="http://115.28.3.15/bbs/forum.php?mod=forumdisplay&fid=41" target="_blank">使用说明</a>&nbsp;&nbsp;&nbsp;
                    <a href="http://115.28.3.15/bbs/forum.php?mod=forumdisplay&fid=40" target="_blank">问题和意见</a>
                </div>

            <?php $this->endWidget(); ?>
            </div>

</div><!-- content -->
</div>
